<template>
  <div class="lang">
    <el-dropdown
      class="avatar-container"
      trigger="click"
      @command="handleCommand"
    >
      <div class="avatar-wrapper">
        <svg-icon icon-class="language" />
      </div>
      <el-dropdown-menu slot="dropdown" class="user-dropdown">
        <!-- <el-dropdown-item divided @click.native="logout"> -->

        <el-dropdown-item
          divided
          command="zh"
          :disabled="$i18n.locale === 'zh'"
        >
          <span style="display: block">中文</span>
        </el-dropdown-item>
        <el-dropdown-item
          divided
          command="en"
          :disabled="$i18n.locale === 'en'"
        >
          <span style="display: block">en</span>
        </el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: 'Lang',
  data() {
    return {}
  },
  computed: {},
  created() {
    console.log(this.$i18n.locale, 88444)
  },
  methods: {
    handleCommand(command) {
      console.log(command)
      this.$i18n.locale = command
    }
  }
}
</script>
<style lang="scss" scoped>
.lang {
  .svg-icon {
    color: #fff;
    font-size: 30px;
    margin-right: 10px;
  }
}
</style>
